package com.carserver.service;

import com.carserver.pojo.User;
import org.springframework.data.domain.Page;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface UserDao extends JpaRepository<User,Integer>, JpaSpecificationExecutor {
    @Query(value = "select * from user where user_name=?1", nativeQuery = true)
    User findUserByName(String name);

    @Query(value = "select * from user where user_pwd=:pwd", nativeQuery = true)
    User findUserByUserPwd(@Param("pwd") String password);

    @Query(value = "select * from user where email=:em", nativeQuery = true)
    User findUserByEmail(@Param("em") String email);
//分页查询
    @Query(value = "select * from user limit :pagenum,:pagesize",nativeQuery = true)
    List<User> findUserByPage(@Param("pagenum") Integer m,@Param("pagesize") Integer n);

    @Query(value = "select count(*) from user",nativeQuery = true)
    Integer getNumAll();

    @Query(value = "select count(*) from user where status=4",nativeQuery = true)
    Integer getNumUser();


}
